<?php 
namespace app\index\controller;
use think\Controller;
use think\Request;

/**
* 评论
*/
class Talk extends Controller
{
	
	public function index()
	 {
	 	$time = time();
	 	$cont = input('post.');
	 	$data = ['uid'=>$cont['uid'],'nid'=>$cont['nid'],'content'=>$cont['editorValue'],'addtime'=>$time];
	 	db('user_talk')->insert($data);
	 	$respond = db('note')->where('id',$cont['nid'])->find()['respond'] + 1;
	 	db('note')->where('id',$cont['nid'])->update(['respond'=>$respond]);
	 	// 加积分
		$user = db('information')->where('userid',session('user')['id'])->find()['jifen'];
		db('information')->where('userid',session('user')['id'])->update(['jifen'=>($user+2)]);
	 	
	 	return $this->success('评论成功',url('post/index',array('id'=>$cont['nid'])));
	 } 
}